﻿@using VirtualPress.Infrastructure.Entities.Entity;
@using VirtualPress.Tool.Framework;
@using VirtualPress.Infrastructure.Entities.Enum;
@{
    ViewBag.Title = "ArticleEdit";
    Layout = "/Areas/WorkSpace/Views/Shared/_WorkSpace.cshtml";
}
<link type="text/css" rel="Stylesheet" href="/content/css/select2.css" />
<div id="content-header">
    <h1>
        编辑稿件</h1>
</div>
<div id="breadcrumb">
    <a href="/WorkSpace/Member/Index" class="tip-bottom"><i class="icon-home"></i>起始页</a>
    <a class="current">编辑稿件</a>
</div>
<div class="container-fluid">
    <div class="row-fluid">
        <div class="span8">
            <div class="widget-box">
                <div class="widget-title">
                    <span class="icon"><i class="icon-pencil"></i></span>
                    <h5>
                        期刊投稿</h5>
                    <h5 style="float: right; color: Red;">
                        *为必填</h5>
                </div>
                @{
                    Meeting meeting = ViewBag.Meeting;
                    Article article = ViewBag.Article;

                    List<Author> author = ViewBag.Author;
                    List<ArticleAuthor> articleAuthor = ViewBag.ArticleAuthor;
                }
                <div class="widget-content nopadding">
                    <form class="form-horizontal" 
                        method="post" enctype="multipart/form-data" 
                        action="/WorkSpace/member/manuscriptedit">
                    <input type="hidden" name="meetingId" value="@meeting.Id" />
                    <input type="hidden" id="hidAuthor" name="Author" />
                    <input type="hidden" name="Status" value="@((int)article.Status)" />
                    <input type="hidden" name="ArticleId" value="@article.Id" />
                    <input type="hidden" name="GJFW" />
                    <div class="step">
                        <div class="control-group">
                            <label class="control-label">
                                会议</label>
                            <div class="controls">
                                <input id="name" readonly="readonly" type="text" name="Name" value="@meeting.Name" />
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">
                                稿件标题 (*)</label>
                            <div class="controls">
                                <input type="text" name="Title" value="@article.Title" class="{required:true}" />
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">
                                英文标题 (*)</label>
                            <div class="controls">
                                <input type="text" name="Title_EN" value="@article.Title_EN" class="{required:true}" />
                            </div>
                        </div>
                        <div id="authorbox" class="control-group">
                            <label class="control-label">
                                添加作者 (*)</label>
                            <div class="controls">
                                <select id="sltAuthor" multiple>
                                   @{
                                       if(author != null && author.Any())
                                       {
                                        for(int i = 0,len = author.Count;i<len;i++)
                                        {
                                            if (articleAuthor.Select(c=>c.AuthorName).Contains(author[i].LastName+author[i].FirstName))
                                            {
                                            <option selected="selected" value="@author[i].Id">@author[i].LastName@author[i].FirstName</option>
                                            }
                                            else
                                            { 
                                            <option value="@author[i].Id">@author[i].FirstName@author[i].LastName</option>
                                            }
                                        }
                                       }
                                       }
								</select>
                                <a style="color:#000;">请按顺序添加</a>
                                <a href="/workspace/member/authorinfo">添加作者</a>
                            </div>
                        </div>
                        <div class="control-group" id="gjfwbox">
                            <label class="control-label">
                                所属范围： </label>
                            <div class="controls">
                            <ul>
                            @{
                                string[] sltfw = article.GJFW.Split(';');
                                string[] fw = meeting.ZGFW.Split(';');
                                if(fw != null && fw.Any())
                                {
                                    int i =0;
                                    foreach(var item in fw)
                                    {
                                        if (String.IsNullOrEmpty(item))
                                        {
                                            continue;
                                        }
                                        string ctlid = "ckbGJFW"+i;
                                        <li>
                                            @if(sltfw.Contains(item))
                                            {
                                                <input id="@ctlid" checked="checked" type="checkbox" value="@item" /><label style="display:inline; padding-left:10px;" for="@ctlid">@item</label>
                                            }
                                            else
                                            {
                                                <input id="@ctlid" type="checkbox" value="@item" /><label style="display:inline; padding-left:10px;" for="@ctlid">@item</label>
                                            }
                                        </li>
                                            i++;
                                    }
                                }
                                }
                            </ul>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">
                                摘要 (*)</label>
                            <div class="controls">
                                <textarea name="Abstract" rows="10" cols="15" class="{required:true}">@article.Abstract</textarea>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">
                                关键字 (*)</label>
                            <div class="controls">
                                <input type="text" name="KeyWords" value="@article.KeyWords" class="{required:true}" />
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">
                                摘要(ENGLISH) (*)</label>
                            <div class="controls">
                                <textarea name="Abstract_EN" rows="10" cols="15" class="{required:true}">@article.Abstract_EN</textarea>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">
                                关键字(ENGLISH) (*)</label>
                            <div class="controls">
                                <input type="text" name="KeyWords_EN" value="@article.KeyWords_EN" class="{required:true}" />
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">
                                原稿件 (*)</label>
                            <div class="controls">
                                <a target="_blank" title="点击下载" href="/download?token=@EncodeByBase64.Encode(new { id = ViewBag.Attachment.Id, type = 1 }.ToJson())">
                                    <i class="icon-file icon-large"></i>
                                    @ViewBag.Attachment.FileName;</a>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">
                                新上传稿件 (*)</label>
                            <div class="controls">
                                <input type="file" name="Appendix" class="{accept:'doc|docx|pdf|zip|7z|rar'}"/>
                            </div>
                        </div>
                        @if(ViewBag.Recommendation != null)
                        {
                        <div class="control-group">
                            <label class="control-label">
                                专家推荐材料</label>
                            <div class="controls">
                                <a target="_blank" title="点击下载" href="/download?token=@EncodeByBase64.Encode(new { id = ViewBag.Recommendation.Id, type = 1 }.ToJson())">
                                    <i class="icon-file icon-large"></i>
                                    @ViewBag.Recommendation.FileName;</a>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">
                                新上传材料</label>
                            <div class="controls">
                                <input type="file" name="Recommendation" class="{accept:'doc|docx|pdf|zip|7z|rar'}"/>
                            </div>
                        </div>
                        }
                    </div>
                    <div class="form-actions">
                        <a class="btn btn-primary" href="/workspace/member/index">返回</a>
                        <input id="btnsubmit" class="btn btn-primary" type="submit" value="Submit" />
                    </div>
                    <div id="submitted">
                    </div>
                    </form>
                </div>
            </div>
        </div>
        <div class="span4">
            <div class="accordion widget-box" id="collapse-group">
                <div class="accordion-group widget-box">
                    <div class="accordion-heading">
                        <div class="widget-title">
                            <a data-parent="#collapse-group" href="#collapseGOne" data-toggle="collapse"><span
                                class="icon"><i class="icon-magnet"></i></span>
                                <h5>
                                    稿件历史记录</h5>
                            </a>
                        </div>
                    </div>
                    <div class="accordion-body collapse" id="collapseGOne">
                        <div class="widget-content">
                            <ul class="activity-list">
                                @{
                                    List<ArticleHistory> his = ViewBag.History;
                                    if (his != null && his.Any())
                                    {
                                        foreach (var item in his)
                                        {
                                        <li>
                                            <a href="javascript:;">
                                                <i class="icon-chevron-right"></i>
                                                <strong>@item.Message</strong>
                                                @item.CurrentStatus.Mapping()
                                                <span>@item.CreateTime.ToString("yyyy-MM-dd")</span>
                                            </a>
                                        </li>
                                        }
                                    }
                                }
                            </ul>
                        </div>
                    </div>
                </div>
                <div class="accordion-group widget-box">
                    <div class="accordion-heading">
                        <div class="widget-title">
                            <a data-parent="#collapse-group" href="#collapseGTwo" data-toggle="collapse"><span
                                class="icon"><i class="icon-magnet"></i></span>
                                <h5>
                                    审稿记录</h5>
                            </a>
                        </div>
                    </div>
                    <div class="accordion-body in collapse" id="collapseGTwo" >
                        <div class="widget-content">
                            <ul class="activity-list">
                                @{
                                    List<AuditingRecord> record = ViewBag.AuditingRecord;
                                    if (record != null && record.Any())
                                    {
                                        foreach (var item in record)
                                        {
                                        <li>
                                            <a href="javascript:;">
                                                <i class="icon-chevron-right"></i>
                                                <strong>@item.Step.Mapping()</strong>
                                                @item.ExamineStatus.Mapping()
                                                <span>@item.CreateTime.ToString("yyyy-MM-dd")</span>
                                                @if (!String.IsNullOrEmpty(@item.Message))
                                                {
                                                    <i style="float:right;" title="@item.Message" class="icon-comment"></i>
                                                }
                                            </a>
                                        </li>
                                        }
                                    }
                                    else
                                    {
                                    <li>
                                    <a href="javascript:;">
                                        <i class="icon-chevron-right"></i>
                                        暂无记录
                                    </a></li>
                                    }
                                }
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@section tail
{
    <script type="text/javascript" src="/scripts/jquery.validate.js"></script>
    <script type="text/javascript" src="/scripts/unicorn.wizard.js"></script>
    <script type="text/javascript" src="/scripts/jquery.metadata.js"></script>
    <script type="text/javascript" src="/scripts/jquery.wizard.js"></script>
    <script type="text/javascript" src="/scripts/select2.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $('#likmtarticle').addClass('active open');
            $('#sltAuthor').select2();
            $('form').validate({
                errorClass: "help-inline",
                errorElement: "span",
                highlight: function (element, errorClass, validClass) {
                    $(element).parents('.control-group').addClass('error');
                },
                unhighlight: function (element, errorClass, validClass) {
                    $(element).parents('.control-group').removeClass('error');
                },
                submitHandler: function (form) {
                    var choose = $('.chooseitem').length;
                    if (choose == 0) {
                        $('#authorbox').addClass('error');
                        $('#authorbox').children('.controls:eq(0)').append(
                            $('<span generated="true" class="help-inline" style="">required.</span>')
                        );
                        return false;
                    }
                    else {
                        $('#authorbox').removeClass('error');
                        $('#authorbox').children('.controls:eq(0)').children('.help-inline:eq(0)').remove();
                    }
                    var sid = "";
                    $('.chooseitem').each(function () {
                        var ci = $(this).children('div').text();
                        $('#sltAuthor').children('option').each(function () {
                            if (ci == $(this).text()) {
                                sid += $(this).val() + ';';
                            }
                        });
                    });
                    $('#hidAuthor').val(sid);
                    var gjfw = '';
                    $(':checkbox:checked').each(function () {
                        gjfw += $(this).val() + ';';
                    });
                    if (gjfw == '') {
                        $(':checkbox:eq(0)').focus();
                        $('#gjfwbox').addClass('error').children('div.controls')
                            .append($('<span generated="true" class="help-inline" style="">required.</span>'));
                        return false;
                    }
                    $('input[name="GJFW"]').val(gjfw);
                    $('#btnsubmit').attr('disabled', 'disabled').val('附件上传中');
                    return true;
                }
            });
        });
    </script>
}